//
//  File.swift
//  MasterBoy
//
//  Created by kyson on 2024/9/20.
//

import Foundation
import YYText

class MBDGroupNameCell : MBDCommonCell {
    var groupNameLabel : YYLabel!
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.initialize()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        self.initialize()
    }
    
    override var cellModel: Any!{
        didSet {
            let realCellModel = self.cellModel as! MBDGroupNameCellModel
            self.groupNameLabel.textLayout = realCellModel.groupNameTextLayout
            
            groupNameLabel.snp.updateConstraints { make in
                make.height.equalTo(realCellModel.groupNameTextLayout!.textBoundingSize.height)
            }
        }
    }

    func initialize() {
        self.contentView.setDynamicForgroundColor()
        self.commonBackgroundView.setDynamicForgroundColor()
        
        self.separateLine.isHidden = true
        
        
        
        groupNameLabel = YYLabel()
        self.commonBackgroundView.addSubview(groupNameLabel)
        groupNameLabel.snp.makeConstraints { make in
            make.top.equalTo(MBDGroupNameCellModel.MarginTop)
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(MBDGroupNameCellModel.MarginNameLabelLeftAndRight)
            make.right.equalToSuperview().offset(-MBDGroupNameCellModel.MarginNameLabelLeftAndRight)
            make.height.equalTo(0)
        }
    }
}
 
